<template>
<div>
  <head-container></head-container>
  <div class="list_main">
    <p class="pos">当前位置：
      <router-link to="/" tag="span">首页</router-link>>
      <router-link to="/forum" tag="span">睿那论坛</router-link>>
      <span>{{title}}</span>
    </p>
    <bbs-section 
      :category='{title:title,id:cid}'></bbs-section>
  </div>
  <foot-container></foot-container>
</div>
</template>
<script>
import bbsSection from '../components/bbsSection'
import headContainer from '../components/headContainer'
import footContainer from '../components/footContainer'
export default {
  data(){
    return {
      cid:this.$route.query.id,
      title:this.$route.params.t,
      data:'',
    }
  },
  components:{
    bbsSection,
    headContainer,
    footContainer
  },
  mounted(){
    //if参数存在获取当前板块帖子列表
    if(this.cid){
      this.GLOBAL.request({
        baseURL:this.GLOBAL.API_RNTY_URL,
        url:'ftopics/c_list',
        param:{
          cid:this.cid
        }
      }).then(({data:data})=>{
        this.data = data;
      })
    }else{
      this.$router.push({path:'/'})
    }
    if (!this.title) {
      this.GLOBAL.request({
        baseURL:this.GLOBAL.API_RNTY_URL,
        url:'ftcates/top_4'
      }).then(({data:data})=>{
        let title = data.filter(item => item.id==this.cid);
        if (!title.length) {
          this.title = '无分区';
          return;
        }
        this.title = title[0].title;
      })
    }
  }
}
</script>
<style scoped>
.head{
  height:50px;
  background-color: #cccccc;
}
.list_main{
  padding-top:116px;
  width:1200px;
  min-height:660px;
  margin:0 auto;
}
.list_main .pos span{
  cursor: pointer;
}
</style>

